package com.tuanzi.loan.core.entity;

import lombok.Data;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * @author Ray 2017/09/21
 */
@Data
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class AuditEntity implements Serializable {

    private static final long serialVersionUID = 7550766086746707203L;

    @CreatedBy
    @Column(name = "CREATOR", length = 50)
    protected String creator;

    @CreatedDate
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "CREATE_TIME")
    protected Date createTime;

    @LastModifiedBy
    @Column(name = "UPDATOR", length = 50)
    protected String updator;

    @LastModifiedDate
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "UPDATE_TIME")
    protected Date updateTime;

    @Version
    @Column(name = "VERSION")
    protected Integer version;

}
